<?php
 
 class Payment_Model_Transaction extends Zend_Db_Table
{

	protected $_name="payment_transaction";
	protected $_primary = 'id';
	
 	public function insertTransaction($arrParam = null, $option = null)
	{	
	  		$row = $this->fetchNew();		  	
			$row->userid       =$arrParam['userid'];						
			$row->payment_type       =$arrParam['payment_type'];
			$row->payment_status     =$arrParam['payment_status'];
			$row->credit       = $arrParam['credit'];
			$row->debit = $arrParam['debit'];
			$row->create_at = date('Y-m-d h:i:s',time());
			$row->updated_at = date('Y-m-d h:i:s',time());
			$row->card_code = $arrParam['card_code'];
			$row->card_seri = $arrParam['card_seri'];
			$row->order_code = $arrParam['order_code'];
		  	return $row->save();
	}
	
	public function getBalanceDateExpire($userid){
		
		$db = Zend_Registry::get('connectDB');
		
		$sql = "select * from payment_transaction inner join user on payment_transaction.userid = user.id where user.expire_date <= payment_transaction.create_at or user.expire_date >= now() and user.id= '".$userid."'";
  		
		return $db->fetchAll($sql);
		
	}
	
        
}